﻿using INTEX.DataBase;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core;
using ReflectionStudio.Core.Events;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.IO;
using System.Linq;
using System.Windows;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {
        public void YGRPDCTOT(DataSet db)
        {
            int x = 2, y = 1;
            DataTable dtOutput = new DataTable();
            try
            {
                #region======Title===========
                int idx = 1;
                int start = 1;
                /*YARN	QTY	COUNT*/
                exAgent.SetCellValue(start, idx++, "纱型纱支"); dtOutput.Columns.Add("YARN", typeof(System.String));
                exAgent.SetCellValue(start, idx++, "数量"); dtOutput.Columns.Add("QTY", typeof(System.String));
                exAgent.SetCellValue(start, idx++, "计算纱支"); dtOutput.Columns.Add("COUNT", typeof(System.String));
                #endregion
                
                exAgent.SetCurrentSheet("YGRPDCTOT");
                exAgent.CopySheet("纱支汇总");                
                dtOutput.Merge(db.Tables["ICC_PDC"], false, MissingSchemaAction.Ignore);
                foreach (DataRow row in dtOutput.Rows)
                {
                    row["YARN"] = GetGB2312Value(row["YARN"].ToString().Trim());
                }
                int count = dtOutput.Rows.Count;
                exAgent.DataTableToExcel(dtOutput, x, 1);
                exAgent.SetCellValue(1, 1, 1);
                exAgent.BatchConvert2Number(2, 2, count + 1, 3);
                exAgent.SetCellValue(1, 1, "纱型纱支");                
                
                exAgent.DeleteSheet("YGRPDCTOT");
                exAgent.SetCurrentSheet("纱支汇总");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            finally
            {
                EventDispatcher.Instance.RaiseStatus("完成", StatusEventType.StopProgress);
            }
        }

    }
}